define(["template"],function(){
    var tpl = {};
    /*
    * 问卷：
    * */
    tpl.questionnaire = function(){
        var html = '';
        html += questionnaire();
        return html;
    };
    var questionnaire = function(){
        return '<script type="text/html" id="questionnaire-tpl">'+
                    '<table class="table table-bordered">'+
                        '<tbody>'+
                            '{{each data as tr}}'+
                                '<tr>'+
                                    '<td>{{tr.name}}</td>'+
                                    '<td name = "{{tr.name}}">'+
                                        '<ol class="item-list">'+
                                            '{{each tr.question as td}}'+
                                                '<li class="clearfix" id="{{td.id}}" topic = "{{td.topic}}">'+
                                                    '<div class="w-18">{{td.topic}}{{if td.topic}}：{{/if}}</div>'+
                                                    '<div class="clearfix w-82 ">'+
                                                        '{{each td.option as op,i}}'+
                                                            '{{if op.type}}'+
                                                                '{{if op.value}}'+
                                                                    '<span color = "{{op.colour}}" type="{{op.type}}" class="{{op.colours}}" name="{{op.name[0]}}" >{{op.name[0]}}：<font>{{op.value}}</font>° </span>'+
                                                                '{{else}}'+
                                                                    '<span color = "{{op.colour}}" type="{{op.type}}" name="{{op.name[0]}}" >{{op.name[0]}}（<font></font>）度</span>'+
                                                                '{{/if}}'+
                                                            '{{else}}'+
                                                                '{{if td.value}}'+
                                                                     '<span color = "{{op.colour}}" {{if td.value == op.name}} class="{{op.colour}}" {{/if}} name="{{td.topic}}" val = "{{op.name}}">{{op.name}}</span>'+
                                                                '{{else}}'+
                                                                    '<span color = "{{op.colour}}" {{if td.topic && i== 0}} class="green" {{/if}} name="{{td.topic}}" val = "{{op.name}}">{{op.name}}</span>'+
                                                                '{{/if}}'+
                                                            '{{/if}}'+
                                                        '{{/each}}'+
                                                    '</div>'+
                                                '</li>'+
                                            '{{/each}}'+
                                        '</ol>'+
                                    '</td>'+
                                '</tr>'+
                            '{{/each}}'+
                        '</tbody>'+
                    '</table>'+
                '</script>'
    };

    /*
    * 弹窗：
    * */
    tpl.modal = function(){
        var html = '';
        html += modal();
        return html;
    };
    var modal = function(){
        return '<script type="text/html" id="modal-tpl">'+
                '<div class="modal fade {{className}}" tabindex="-1" role="dialog">'+
                    '<div class="modal-dialog" role="document">'+
                        '<div class="modal-content">'+
                            '<div class="modal-header">'+
                                '<h4 class="modal-title">{{title}}</h4>'+
                            '</div>'+
                            '<div class="clearfix modal-body">'+
                                '<div class="clearfix">' +
                                    '<span class="modal-left text-right">请输入 <font>{{itemTitle}}</font>度数：</span>' +
                                    '<span><input type="{{type}}" {{if type == "number"}} min="0"  {{/if}} class="form-control" id="angle" name="{{itemTitle}}" value="{{value}}"/></span>' +
                                '</div>'+
                                '<div class="clearfix">' +
                                    '<span class="modal-left"></span>' +
                                    '<span><button class="btn btn-primary" id="sureAngle">确定</button><button class="btn btn-default pull-right" id="cancel">取消</button></span>' +
                                '</div>'+
                            '</div>'+
                        '</div>'+
                    '</div>'+
                '</div>'+
                '</script>'
    };
    return tpl;
});